{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "150\n",
      "147\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Iris-versicolor    50\n",
       "Iris-virginica     49\n",
       "Iris-setosa        48\n",
       "Name: class, dtype: int64"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "97"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(r\"dataset/iris.arff.csv\", header=0)\n",
    "# data.head(10)\n",
    "# data.tail(10)\n",
    "# print(data.sample(10))\n",
    "# data = data.drop(\"Id\",axis=1)  # 删除列\n",
    "print(len(data))\n",
    "if data.duplicated().any(): # 重复值\n",
    "    data.drop_duplicates(inplace=True) #删除重复值\n",
    "    print(len(data))\n",
    "display(data[\"class\"].value_counts()) # 计算每个类别的数量\n",
    "# 因为感知器映射结果为1和-1，所以这里这也处理\n",
    "data[\"class\"] = data[\"class\"].map({\"Iris-versicolor\":0,\"Iris-setosa\":-1,\"Iris-virginica\":1}) # 类别名称映射为数字\n",
    "data = data[data[\"class\"]!=0]\n",
    "len(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Perception:\n",
    "    '''感知器算法实现。二分类'''\n",
    "    def __init__(self, learning_rate, times):\n",
    "        '''初始化\n",
    "        \n",
    "        Parameters\n",
    "        -----\n",
    "        learning_rate: float 学习率\n",
    "        times: int 迭代次数\n",
    "        '''\n",
    "        self.learning_rate = learning_rate\n",
    "        self.times =  times\n",
    "    def step(self, z):\n",
    "        '''阶跃函数\n",
    "        \n",
    "        Paraammeters\n",
    "        -----\n",
    "        z: 数组类型(或者是标量) 阶跃函数参数。将z映射为1或者-1\n",
    "        \n",
    "        Return\n",
    "        -----\n",
    "        value: int z>0返回1.z<0返回1\n",
    "        '''\n",
    "        return np.where(z>0, 1,-1) # 一步实现对数值或者数组的计算返回\n",
    "    def fit(self, X, y):\n",
    "        '''训练\n",
    "        \n",
    "        Parameters\n",
    "        -----\n",
    "        X: 特征矩阵，可以是List也可以是Ndarray，形状为： [样本数量,特征数量]\n",
    "        y: 标签数组\n",
    "        '''\n",
    "        X = np.asarray(X)\n",
    "        y = np.asarray(y)\n",
    "        # 创建权重向量。初始值为0。长度比特征多1.多出的是截距\n",
    "        self.w_ = np.zeros(1 + X.shape[1])\n",
    "        # 创建损失列表，用来保存每次迭代后的损失值\n",
    "        self.loss_ = []\n",
    "        for i in range(self.times):\n",
    "            # 感知器与逻辑回归的区别：逻辑回归中。使用所有样本计算梯度来更新权重。\n",
    "            # 而感知器是使用单个样本，依次计算梯度更新权重\n",
    "            loss = 0\n",
    "            for x,target in zip(X,y):\n",
    "                # 计算预测值\n",
    "                y_hat = self.step(np.dot(x, self.w_[1:]) + self.w_[0])\n",
    "                # 如果预测值不等于目标值，返回1，loss+1，否则loss不增加\n",
    "                loss += y_hat != target\n",
    "                # 更新权重\n",
    "                # w(j) = w(j) + 学习率 * (真实值-预测值)*x(j)\n",
    "                self.w_[0] += self.learning_rate * (target - y_hat)\n",
    "                self.w_[1:] +=  self.learning_rate * (target - y_hat) * x\n",
    "            # 将循环累计误差值增加到误差列表中\n",
    "            self.loss_.append(loss)\n",
    "    def predit(self, X):\n",
    "        '''根据参数预测\n",
    "        \n",
    "        Parametres:\n",
    "        X: 特征矩阵，可以是List也可以是Ndarray，形状为： [样本数量,特征数量]\n",
    "        \n",
    "        Return\n",
    "        -----\n",
    "        value: 数组类型， 分类值[1或-1]\n",
    "        '''\n",
    "        return self.step(np.dot(X, self.w_[1:]) + self.w_[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1,  1,  1,  1,  1,  1,  1,  1,  1, -1, -1, -1, -1, -1, -1, -1, -1])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([ 1,  1,  1,  1,  1,  1,  1,  1,  1, -1, -1, -1, -1, -1, -1, -1, -1],\n",
       "      dtype=int64)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([-0.2 , -0.5 , -0.68,  1.56,  0.88])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "[3, 2, 0, 0, 0, 0, 0, 0, 0, 0]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "t1 = data[data[\"class\"]==1]\n",
    "t2 = data[data[\"class\"]==-1]\n",
    "t1.sample(len(t1), random_state=0)\n",
    "t2.sample(len(t2), random_state=0)\n",
    "train_X = pd.concat([t1.iloc[:40,:-1], t2.iloc[:40, :-1]], axis=0)\n",
    "train_y = pd.concat([t1.iloc[:40,-1], t2.iloc[:40, -1]], axis=0)\n",
    "test_X = pd.concat([t1.iloc[40:,:-1], t2.iloc[40:, :-1]], axis=0)\n",
    "test_y = pd.concat([t1.iloc[40:,-1], t2.iloc[40:, -1]], axis=0)\n",
    "\n",
    "p = Perception(0.1, 10)\n",
    "p.fit(train_X,train_y)\n",
    "result = p.predit(test_X)\n",
    "# result\n",
    "display(result)\n",
    "display(test_y.values)\n",
    "display(p.w_)\n",
    "display(p.loss_) # 可以看出每次迭代后损失值就下降了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib as mpl\n",
    "import matplotlib.pyplot as plt\n",
    "mpl.rcParams[\"font.family\"] = \"SimHei\"\n",
    "mpl.rcParams[\"axes.unicode_minus\"] = False # 显示负号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metad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UNSQ/mvk9cBBJiA01Q/UYuAI4HLguPQZOrnWHACLibSXHwFBZALIU+LSkB4CTgL8/EEVH3I+zJL0RWAf8G3AaMGuIjSrMBoSkNRHRKumtwN3A/cAJJMeAr0dtwAgMfXj9Y+QCYG06H2aWK5IOJRnt3+tBjxUbkaFvZmbljcQ5fTMzq8Chb1aFWp46wOxAcOibVSDp65IOlXSupM9JmgD8RNK49PmfSvpZensp/QVxz74PSPLxZUOO/1GalSFpNMkPYv4vsIvkV69XAF8FdqYj/l0RMTsiZgMdEdEt6RZJbwO6I+K1WvXfrJLRte6A2VCT/nL6n0nORzQOuJPkdBDbgWOBxcCngLqik/odkf5gawewc9A7bdZPHumblYiIrekPda4h+XXrVSQ/FHsIeBG4JCL+C7gUeBPwR5Jzt3gpnA15HumblSHpeuAp4EPAHKApIi6T9F6S01b8A/B+4B0kZ4yEIXhqarNSDn2zEpLeSRLmR5Cc5O3NwOT0DKmQhPujJKc7mENy5s0C8D5A6c1sSHLom5WIiF8A8wAkjQXuAZ4F/iYiHuhpl87hfw34R+B4kjeHJ0m++DUbkjynb1aGpDekF275V5I5/QuARZKWp5fVG0syz7+SZPD0TuDliLiG5AI5E2rUdbM+eaRvVkLSwcD3SC7Cc27RtQYulLSAZBlnJ7AxIv6fpFNITmz2pbTdXSQnOzMbcnzuHTOzHPH0jplZjjj0zcxyxKFvZpYjDn0zsxxx6JuZ5YhD38wsR/4/R1ZVE/gHJesAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制真实值\n",
    "plt.plot(test_y.values, \"go\", ms=15, label=\"真实值\")\n",
    "plt.plot(result, \"rx\", ms=15, label=\"预测值\")\n",
    "plt.title(\"感知器二分类\")\n",
    "plt.xlabel(\"样本序号\")\n",
    "plt.xlabel(\"类别\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x22730e15ac8>]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAD2CAYAAAAksGdNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAYu0lEQVR4nO3df3Dc9X3n8edbK8mS5R+SVsLEwr+02E5JjDEI410IFYQfSS7XuDQNveGSSeHGl1xI0+SOOZhw02mGNp1Q6KVkIPWVtAy9a+vMEc/QJGdDza+ADMgYMFBssPEvGYNsWZZlyz8kve8PrbEt9GMlfbWf/fF6zGi82v149zU79ssfv79f7dfcHRERyW8loQOIiMjEqcxFRAqAylxEpACozEVECoDKXESkAJSGeNG6ujqfP39+iJcWEclbmzZtOuDu9UM9FqTM58+fT2tra4iXFhHJW2a2a7jHNGYRESkAKnMRkQKgMhcRKQAqcxGRAqAyFxEpABmdzWJmtcBlwGZ3PzC5kYa3dnMb967byr7OHmZXV3LHjYtZuawhVBwRkZwx6s7czGqAfwGWA0+Z2ZDnOJrZw2bWYmZ3R5wRGCjyux7bQltnDw60dfZw12NbWLu5bTJeTkQkr2QyZrkY+J67/xmwDrh08AIzuwmIuXsSaDSzhdHGhHvXbaXnVN859/Wc6uPedVujfikRkbwzapm7+zPuvtHMrmZgd94yxLJmYE369nrgqsELzGyVmbWaWWt7e/uYg+7r7BnT/SIixSSjA6BmZsDNwCHg1BBLqoDT844OYNbgBe6+2t2b3L2pvn7ISc2IZldXjul+EZFiklGZ+4BvAa8DvzPEkm7gdKtOy/R5x+KOGxdTWRY7577Kshh33Lg46pcSEck7mRwA/e9m9rX0t9VA5xDLNnFmtLIU2BlJurOsXNb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fDzObB/wKeBJIMXDN5L4JP7/KXEQku8xsNgO783VRXTNZZS4iUgA0MxcRKQAqcxGRAqAyFxEpACpzEZECoDIXESkA/x97NnHxqlDMmwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制目标函数损失值\n",
    "plt.plot(range(1, p.times+1), p.loss_, \"o-\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
